package org.yanghe.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ProviderController {

    @Value("${server.port}")
    private String port;


  /*
    //不支持动态更新
    @Value("${common.name}")
    private String content;*/

    //注入配置文件上下文
    @Resource
    private ConfigurableApplicationContext applicationContext;

    @RequestMapping("/provider/hello/{name}")
    public String hello(@PathVariable("name") String name){
        String content = applicationContext.getEnvironment().getProperty("common.name");
        return name+" Welcome To ProviderController "+port+" "+content;
    }
}

